<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>查询配置新增</title>
    <%@include file="../../sys_common_head.jsp"%>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">

                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">id</label>
                    <div class="layui-input-block">
                        <input type="text" value="${sqlQuery.id}" name="id" id="id"
                               autocomplete="off" placeholder="请输入id" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">配置列显示</label>
                    <div class="layui-input-block">
                        <textarea id="colConfig" name="colConfig" placeholder="请输入内容" class="layui-textarea">${sqlQuery.colConfig}</textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">查询的sql</label>
                    <div class="layui-input-block">
                        <textarea id="sqlVar" name="sqlVar" placeholder="请输入内容" class="layui-textarea">${sqlQuery.sqlVar}</textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="data-update">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'jquery','laydate'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        var laydate = layui.laydate;
        // 日期选择
        laydate.render({
            elem: '#birthday' //指定元素
        });

        form.on('submit(data-update)', function (data) {
            $.ajax({
                url: '<%=request.getContextPath()%>/student/sqlquery/update',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'PUT',
                success: function (result) {
                    if (result.code == 0) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("data-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })
</script>

</body>
</html>